﻿// E-Book Copier
// Copyright (C) 2009 Chuan-Gen Fan
// 
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
// 
// Project: http://code.google.com/p/ebookcopier/
// Contact Author:
//    website: http://chuangen.name/
// e-mail/msn: chuangen@live.cn

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace EbookCopier
{
    public partial class MainForm
    {
        /// <summary>
        /// 根据状态更新界面。
        /// </summary>
        public void UpdateButtons()
        {
            switch (captureHelper.CaptureState)
            {
                case CaptureState.Stop://停止状态，
                    //可以SetRect和Capture
                    tsbSetRect.Enabled = true;
                    tsbCapture.Enabled = true;
                    ////翻页可用
                    //tsbPrevPage.Enabled = true;
                    //tsbNextPage.Enabled = true;
                    //开始可用，暂停和停止不可用
                    tsbStart.Enabled = true;
                    tsbPause.Enabled = false;
                    tsbStop.Enabled = false;

                    tsbStart.Checked = false;
                    tsbPause.Checked = false;

                    if (captureHelper.ReaderState != ReaderState.RunningAndOpenDocument)
                    {
                        ////翻页可用
                        //tsbPrevPage.Enabled = false;
                        //tsbNextPage.Enabled = false;

                        tsbStart.Enabled = false;
                    }
                    else
                    {
                        ////翻页可用
                        //tsbPrevPage.Enabled = true;
                        //tsbNextPage.Enabled = true;

                        tsbStart.Enabled = true;
                    }
                    break;
                case CaptureState.Pause://暂停状态
                    //可以SetRect和Capture
                    tsbSetRect.Enabled = true;
                    tsbCapture.Enabled = true;
                    ////翻页可用
                    //tsbPrevPage.Enabled = true;
                    //tsbNextPage.Enabled = true;
                    //开始不可用，暂停被选中，停止可用
                    tsbStart.Enabled = true;
                    tsbPause.Enabled = true;
                    tsbStop.Enabled = true;

                    tsbStart.Checked = false;
                    tsbPause.Checked = true;
                    break;
                case CaptureState.Run://自动捕捉状态
                    //不可以SetRect和Capture
                    tsbSetRect.Enabled = false;
                    tsbCapture.Enabled = false;
                    ////翻页不可用
                    //tsbPrevPage.Enabled = false;
                    //tsbNextPage.Enabled = false;
                    //开始不可用，暂停和停止可用
                    tsbStart.Enabled = true;
                    tsbPause.Enabled = true;
                    tsbStop.Enabled = true;

                    tsbStart.Checked = true;
                    tsbPause.Checked = false;
                    break;
            }
        }
        void Tool_CaptureScreen()
        {
            captureHelper.CaptureScreen();
        }
        void Tool_SetSelectedRect()
        {
            captureHelper.SetSelectedRect();
        }
        void Tool_Start()
        {
            captureHelper.Start();
        }
        void Tool_Pause()
        {
            captureHelper.Pause();
        }
        void Tool_Stop()
        {
            captureHelper.Stop();
        }
    }
}